<script setup lang="ts">
import { useRoute, useRouter } from 'vue-router'
import { onMounted } from 'vue'
import { message, Modal } from 'ant-design-vue'

onMounted(() => {
  const route = useRoute()
  const router = useRouter()
  const params = route.query as RedirectMessage

  router.push(params.url && !params.url.startsWith('/redirect') ? params.url : '/').then(() => {
    if (params.confirm === 'on') {
      const config = { title: params.content }
      switch (params.level) {
        case "success":
          Modal.success(config)
          break
        case "warning":
          Modal.warning(config)
          break
        case "error":
          Modal.error(config)
          break
        default:
          Modal.info(config)
      }
    } else {
      const config = { content: params.content }
      switch (params.level) {
        case "success":
          message.success(config)
          break
        case "warning":
          message.warning(config)
          break
        case "error":
          message.error(config)
          break
        default:
          message.info(config)
      }
    }
  })
})

</script>

<template>

</template>